package com.generarot;

import java.util.ArrayList;
import java.util.List;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.api.ProgressCallback;
import org.mybatis.generator.api.VerboseProgressCallback;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

/**
 * @author HuangSuip
 */
public class MyBatisGeneratorMain {
    public static void generatorRewirte() throws Exception {
        List<String> warnings = new ArrayList<String>();
        boolean overwrite = true;
        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(MyBatisGeneratorMain.class.getClassLoader().getResourceAsStream("generatorConfig.xml"));
        DefaultShellCallback callback = new DefaultShellCallback(overwrite);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
        ProgressCallback progressCallback = new VerboseProgressCallback();
        // myBatisGenerator.generate(null);
        myBatisGenerator.generate(progressCallback);
        System.out.println("----ok----");
    }

    public static void main(String[] args) {
        try {
            MyBatisGeneratorMain.generatorRewirte();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
